<template>
  <comment>
    <div v-if="commentRates && Object.keys(commentRates).length !== 0" class="comment-more">
      <div class="comment-user">
        <p>用户评价</p>
        <p>更多<img src="~assets/images/detail/Detail.png" alt=""></p>
      </div>
      <div class="comment-item" v-for="item in commentRates.rate">
        <div class="commentImg">
          <img :src="item.user.avatar" alt="">
          {{item.user.uname}}
        </div>
        <div class="comment-txt">
          <p>{{item.content}}</p>
        </div>
        <div class="commentTime">
          <div class="time">{{item.created | showTime}}</div>
          <div class="color">{{item.style}}</div>
        </div>
      </div>
    </div>
  </comment>
</template>

<script>
  import Comment from "components/content/comment/Comment";
  import {formatDate} from "common/util";

  export default {
    name: "CommentListItem",
    components: {
      Comment
    },
    props: {
      commentRates: {
        type: Object,
        default(){
          return {};
        }
      }
    },
    filters: {
      showTime(time){
        return formatDate(new Date(time * 1000),"yyyy-MM-dd hh:mm:ss")
      }
    }
  }
</script>

<style scoped>
  .comment-more{
    padding: 10px;
    background-color: white;
  }
  .comment-user{
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    font-size: 15px;
    color: #000;
    border-bottom: 1px solid rgba(0,0,0,.1);
  }
  .comment-user p img{
    width: 15px;
    height: 15px;
    transform: rotate(180deg);
    margin-top: -5px;
    vertical-align: middle;
  }
  .comment-item{
    padding: 10px 5px;
  }
  .comment-item .commentImg img{
    width: 50px;
    height: 50px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 5px;
  }
  .comment-txt{
    margin: 10px 0 10px 3px;
    font-size: 14px;
  }
  .comment-txt p{
    line-height: 25px;
  }
  .commentTime{
    display: flex;
    color: #999;
    font-size: 12px;
  }
  .commentTime .time{
    margin-right: 5px;
  }
</style>